/** 手机号码验证 */
export const verifyMobile = /^(?:(?:\+|00)86)?1\d{10}$/;

/** 身份证验证 */
export const verifyIDCard =
   /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/;

/** 密码验证 */
export const verifyPWD = /[a-zA-Z0-9]{6,20}/;

export const verifyJSON = (str: any) => {
   if (typeof str === "string") {
      try {
         var obj = JSON.parse(str);
         // 等于这个条件说明就是JSON字符串 会返回true
         if (typeof obj == "object" && obj) {
            return true;
         } else {
            //不是就返回false
            return false;
         }
      } catch (e) {
         return false;
      }
   }
   return false;
};
